package com.ysc.plugin.common.abstract

import android.app.Activity
import com.ysc.plugin.common.`interface`.PluginInterFace

abstract class Plugin : PluginInterFace{

    private var mPluginManagerMap:MutableMap<String,Manager> = mutableMapOf()
    private var mActivity: Activity? = null

    fun getActivity():Activity?{
        return mActivity
    }

    fun setActivity(activity:Activity){
        mActivity = activity
    }

    abstract fun initialize(activity:Activity)

    fun getPluginManager():MutableMap<String,Manager>{
        return mPluginManagerMap
    }

    fun getPluginManagerByName(name:String):Manager?{
        return mPluginManagerMap.get(name)
    }

    fun getPluginManagerCounts():Int{
        return mPluginManagerMap.size
    }

    abstract fun initManager()

    fun addPluginManager(pluginManager: Manager) {
        pluginManager.initialize(mActivity!!)
        mPluginManagerMap.put(pluginManager.getName(),pluginManager)
    }
}